<?php
// +---------------------------------------------------------------------+
// | ALINEJUN    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/ALINEJUN                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 美食控制器
 */
class Foods extends AdminBase
{
    
    /**
     * 美食列表
     */
    public function foodsList()
    {
        
        $where = $this->logicfoods->getWhere($this->param);
        
        $this->assign('list', $this->logicfoods->getFoodsList($where, '*', 'create_time desc'));
        
        return $this->fetch('foods_list');
    }
    
    /**
     * 美食添加
     */
    public function foodsAdd()
    {
        
        $this->foodsCommon();
        $this->getCitySelectData();
        return $this->fetch('foods_edit');
    }
    /**
     * 获取城市Select结构数据
     */
    public function getCitySelectData()
    {

        $city_select = $this->logicCity->cityToSelect($this->cityListTree);

        $this->assign('city_select', $city_select);
    }
    /**
     * 美食编辑
     */
    public function foodsEdit()
    {
        
        $this->foodsCommon();
        
        $info = $this->logicfoods->getFoodsInfo(['id' => $this->param['id']], '*');
        
        !empty($info) && $info['img_ids_array'] = str2arr($info['img_ids']);
        $this->assign('info', $info);
        $this->getCitySelectData();
        return $this->fetch('foods_edit');
    }
    
    /**
     * 美食添加与编辑通用方法
     */
    public function foodsCommon()
    {
        
        IS_POST && $this->jump($this->logicfoods->foodsEdit($this->param));
        
       // $this->assign('foods_category_list', $this->logicfoods->getfoodsCategoryList([], 'id,name', '', false));
    }


    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('foods', $this->param));
    }
}
